﻿@using hc.epm.DataModel.Business;
@using System.Collections.Generic;
@using hc.epm.Common
@using hc.Plat.Common.Extend;
@model List<Epm_SignInformation>
@{
    ViewBag.Title = "考勤记录";
}
<div class="content-right date-wrap fl c">
    <div class="search mt5">
        <form class="layui-form" action="" method="get">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">用户名 : </label>
                    <div class="layui-input-inline"><input type="text" name="name" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="@ViewBag.name" /></div>
                    <label class="layui-form-label">项目名称 : </label>
                    <div class="layui-input-inline"><input type="text" name="projectName" placeholder="请输入项目名称" autocomplete="off" class="layui-input" value="@ViewBag.projectName" /></div>

                    <label class="layui-form-label">加油站名称 : </label>
                    <div class="layui-input-inline"><input type="text" name="oilName" placeholder="请输入加油站名称" autocomplete="off" class="layui-input" value="@ViewBag.oilName" /></div>
                    <br />
                    
                </div>

                <div>
                    <label class="layui-form-label">签到时间 : </label>
                    <div class="layui-input-inline">
                        <input type="text" name="time" id="time" placeholder="开始时间" autocomplete="off" class="layui-input" value="" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" />
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" name="endtime" id="endtime" placeholder="结束时间" autocomplete="off" class="layui-input" value="" onclick="WdatePicker({dateFmt: 'yyyy-MM-dd'})" />
                    </div>
                </div>
                <input type="submit" class="layui-btn layui-btn-radius layui-btn-warm" style="margin-top: auto;" lay-filter="search" value="搜 索" id="search" />

            </div>
        </form>
    </div>
    <div class="main mt5">
        <div class="layui-form">
            <table class="layui-table" style="text-align:center;word-break:break-all;word-wrap:break-word">
                <thead>
                    <tr>
                        <th width="5%" class="table-center">
                            <input type="checkbox" lay-skin="primary" lay-filter="allChoose" />
                        </th>
                        <th class="table-center">序号</th>
                        <th class="table-center">用户名称</th>
                        <th class="table-center">项目名称</th>
                        <th class="table-center">加油站名称</th>
                        <th class="table-center">岗位信息</th>
                        <th class="table-center">签到时间</th>
                        <th class="table-center">签到状态</th>
                        <th class="table-center">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @{
                        int index = 0;
                    }
                    @if (Model != null && Model.Count() > 0)
                    {
                        foreach (var item in Model)
                        {
                            index++;
                            <tr>
                                <td class="table-center">
                                    <input type="checkbox" lay-skin="primary" />
                                    <input type="hidden" name="id-@item.SId" id="id-@item.SId" value="@item.SId" />
                                </td>
                                <td class="table-center">@index</td>
                                <td>@item.userName</td>
                                <td>@item.projectName</td>
                                <td>@item.gasstationName</td>
                                <td>@item.jobInfo</td>
                                <td>@(item.SignTime == null ? "" : Convert.ToDateTime(item.SignTime).ToString("yyyy-MM-dd"))</td>
                                @*<td>@item.SignResult</td>*@
                                <td>@(item.SignResult == SignRes.Fail.ToString() ? "签到失败" : item.SignResult == SignRes.Success.ToString() ? "签到成功" : item.SignResult == SignRes.Other.ToString() ? "其他" : item.SignResult == SignRes.NoNetwork.ToString() ? "没有网络" : item.SignResult == SignRes.NoFace.ToString() ? "没有识别到人脸" : "")</td>
                                <td class="table-center">
                                    <a href="javascript:;" class="detail-link" data-itemid="@item.SId" title="详情"><i class='glyphicon glyphicon-list-alt handle-blue'></i></a>
                                </td>
                            </tr>
                        }
                    }
                    else
                    {
                        <tr>
                            <td colspan="7" class="table-center">
                                暂无数据
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
        <div id="page"></div>
    </div>
</div>
<script>
    //若无数据隐藏分页组件
    if ('@ViewBag.Total' == 0) {
        $("#page").hide();
    }
    layui.use(['layer', 'form', 'element', 'laypage'], function () {
        var layer = layui.layer, form = layui.form, element = layui.element, $ = layui.jquery, laypage = layui.laypage;

        //全选
        form.on('checkbox(allChoose)', function (data) {
            var child = $(data.elem).parents('table').find('tbody input[name="chName"]');
            child.each(function (index, item) {
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        //分页
        laypage.render({
            elem: 'page',
            count: '@ViewBag.Total',
            curr: '@ViewBag.pageIndex',
            layout: ['prev', 'page', 'next', 'skip', 'count', ],
            jump: function (obj, first) {
                if (!first) {
                    //得到了当前页，用于向服务端请求对应数据
                    var curr = obj.curr;
                    var search = $("form").serialize();
                    window.location.href = "/User/GetSignInfoList?pageIndex=" + curr + "&" + search;
                }
            }
        });

        //详情
        $("body").on("click", ".detail-link", function () {
            var id = $(this).data("itemid");
            if (id != "") {
                parent.layer.open({
                    type: 2,
                    title: GetLayerTitle("考勤管理-详情"),
                    shadeClose: false, //点击遮罩关闭层
                    area: [BigLayerWidth, '600px'],
                    content: '/User/GetSignInfoDetails/' + id
                });
            }

        });
    });
</script>